//
//  BJSouSuoViewController.m
//  DangXiao
//
//  Created by APPLE on 16/12/9.
//  Copyright © 2016年 APPLE. All rights reserved.
//

#import "BJSouSuoViewController.h"

@interface BJSouSuoViewController ()

@end

@implementation BJSouSuoViewController


- (void)viewDidLoad {
    [super viewDidLoad];
//    self.navigationItem.title = @"搜索";
    self.view.backgroundColor = GrayLabel;
    [self initNavView];
}

static UITextField *inputSearchTF;
- (void)initNavView{
    UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 20, ScreenWidth, 70)];
    [self.view addSubview:navView];
    navView.backgroundColor = [UIColor whiteColor];
    
    UIButton *backBtn = [Utils createBtnWithType:(UIButtonTypeCustom) backgroundColor:ClearColor title:nil image:@"return_b" font:10];
    [backBtn addTarget:self action:@selector(didClickReurnBtn:) forControlEvents:(UIControlEventTouchUpInside)];
    [navView addSubview:backBtn];
    [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(navView.mas_centerY);
        make.left.mas_equalTo(BILIWIDTH(10));
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(40), BILIHEIGHT(20)));
    }];
    
    UIButton *searchBtn = [Utils createBtnWithType:(UIButtonTypeCustom) backgroundColor:ClearColor title:@"搜索" image:nil font:20];
    [searchBtn setTitleColor:BaseColor forState:(UIControlStateNormal)];
    [searchBtn addTarget:self action:@selector(didClickSearchBtn:) forControlEvents:(UIControlEventTouchUpInside)];
    [navView addSubview:searchBtn];
    [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(navView.mas_centerY);
        make.right.mas_equalTo(BILIWIDTH(-10));
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(40), BILIHEIGHT(20)));
    }];
    
    UIView *searchView = [[UIView alloc]init];
    [navView addSubview:searchView];
    BJViewBorderRadius(searchView, 3, 1.0, GrayLabel);
    [searchView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(navView.mas_centerY);
        make.right.equalTo(searchBtn.mas_left).offset(-BILIWIDTH(10));
        make.left.equalTo(backBtn.mas_right).offset(BILIWIDTH(10));
        make.height.mas_equalTo(BILIHEIGHT(40));
    }];
    
    UIImageView *searchImageView = [[UIImageView alloc]init];
    [searchView addSubview:searchImageView];
    searchImageView.image = [UIImage imageNamed:@"ss_s"];
    [searchImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(searchView.mas_centerY);
        make.left.mas_equalTo(BILIWIDTH(10));
        make.size.mas_equalTo(CGSizeMake(BILIWIDTH(22), BILIHEIGHT(22)));
    }];
    
    inputSearchTF = [[UITextField alloc]init];
    [searchView addSubview:inputSearchTF];
    inputSearchTF.font = FontVlaue(15);
    inputSearchTF.placeholder = @"请输入搜索内容";
    [inputSearchTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(searchView.mas_centerY);
        make.right.mas_equalTo(-BILIWIDTH(10));
        make.left.equalTo(searchImageView.mas_right).offset(BILIWIDTH(10));
        make.height.mas_equalTo(BILIHEIGHT(35));
    }];

}

-(void)initUI{
    
    NSMutableArray *titleArr = [[NSMutableArray alloc]initWithObjects:@"我",@"是",@"大",@"美",@"女", nil];
//
    UILabel *tipLabel = [Utils labelWithTitle:@"搜索热词" titleFontSize:18 textColor:BlackTextColor backgroundColor:ClearColor alignment:1];
    [self.view addSubview:tipLabel];
    [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(64 + BILIHEIGHT(50));
        make.left.mas_equalTo(BILIWIDTH(20));
    }];

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.backgroundColor = [UIColor whiteColor];
            [btn setTitle:titleArr.firstObject forState:UIControlStateNormal];
            [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            btn.tag = (i + (3 * j) + 1) + 100;
            [btn addTarget:self action:@selector(clickedBtnWith:) forControlEvents:UIControlEventTouchUpInside];
            btn.frame = CGRectMake(BILIWIDTH(20) + i * BILIHEIGHT(90), 64 + BILIHEIGHT(90) + j * BILIHEIGHT(35), BILIWIDTH(70), BILIWIDTH(25));
            [self.view addSubview:btn];
        }
    }

}

- (void)clickedBtnWith:(UIButton *)btn{
    
}

#pragma mark ---- 点击返回
- (void)didClickReurnBtn:(UIButton *)btn{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark ---- 点击“搜索”按钮
- (void)didClickSearchBtn:(UIButton *)btn{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
}

@end
